package util;

import java.util.Random;
import java.util.Vector;

public class DjRandomArray extends Vector {

	public static synchronized int[] createFrom1To(int maxNum) {

		Vector nonrandomVec = new Vector(maxNum);
		for (int i = 0; i < maxNum; i++) {
			nonrandomVec.addElement(new Integer(i));
		}

		int[] arr = new int[maxNum];
		Random random = new Random();

		for (int i = 0; i < maxNum; i++) {

			int randomNum = random.nextInt(nonrandomVec.capacity());//capacity값이 1씩 줄어듬

			arr[i] = ((Integer) nonrandomVec.elementAt(randomNum)).intValue();

			nonrandomVec.removeElementAt(randomNum);
			nonrandomVec.trimToSize();
		}

		return arr;
	}
}


